﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0, user-scalable=no" />
<link rel="shortcut icon" href="/Images/ico/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="/css/swiper.min.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link type="text/css" rel="stylesheet" href="/layui/css/layui.css"  media="all">
<script type="text/javascript" src="/layui/layui.js" charset="utf-8"></script>
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script src="/js/swiper.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/layui-post.js"></script>
<style type="text/css">
.layui-layer-content{background:#fff}
.layui-layer-nobg{border-radius: 10px 10px 0 0!important;}
.layui-layer-title{border-radius: 10px 10px 0 0!important;}
.white-color{background: #fff;border-radius: 7px;}
</style>
</head>
<body style="background: #F0F0F0;padding: 10px;">
    <div class="ng-scope">
        <header class="ng-scope" id="gwc">
            <h4 class="title-order">
                <a class="title-top" href="javascript:window.history.back();"></a>
                <a class="title-center">评价</a>
                <a class="title-right" style="background: none; line-height: inherit; text-align: left;">
                    <button class="layui-btn layui-btn-xs" id="subDiscuss">提交</button>
                </a>
            </h4>
        </header>
        <div class="white-color" style="margin-top: 50px;">
            <p class="orderno ng-binding ng-scope" style="font-size: 20px;font-weight: bold;">您对商品满意吗？</p>
            <section class="prolist_section" style="padding-bottom: 0;margin-top: 10px;">
                <ul id="prolist" class="lists white-color" style="padding: 10px;"></ul>
            </section>
        </div>
        <div class="white-color" style="margin-top: 10px;padding: 10px;">
            <ul>
                <li>总体：<div id="descLv"></div><input id="descLvVal" type="number" value="5" style="display: none;"></li>
                <li>口味：<div id="qualityLv"></div><input id="qualityLvVal" type="number" value="5" style="display: none;"></li>
                <li>服务：<div id="serverLv"></div><input id="serverLvVal" type="number" value="5" style="display: none;"></li>
                <li>物流：<div id="logisticsLv"></div><input id="logisticsLvVal" type="number" value="5" style="display: none;"></li>
            </ul>
            <div>
                <textarea id="content" class="layui-input" placeholder="说说味道怎么样，给大家参考" style="height: 100px;border-radius: 10px;"></textarea>
            </div>
        </div>
    </div>
</body>
<script>
$.ajaxSetup({contentType: "application/json; charset=utf-8"});
var userInfo = $.parseJSON(sessionStorage.getItem("userInfo"));
var goodsIds = []
layui.use(['layer','form','rate','util'], function(){
    var rate = layui.rate;
    rate.render({
        elem: '#descLv',value: 5,text: true,setText: function(value){
            var arrs = {'1': '极差','2': '差','3': '中等','4': '好','5': '极好'};
            this.span.text(arrs[value] || ( value + "星"));
        },choose: function(value){$("#descLvVal").val(value)}
    })
    rate.render({
        elem: '#qualityLv',value: 5,text: true,setText: function(value){
            var arrs = {'1': '极差','2': '差','3': '中等','4': '好','5': '极好'};
            this.span.text(arrs[value] || ( value + "星"));
        },choose: function(value){$("#qualityLvVal").val(value)}
    })
    rate.render({
        elem: '#serverLv',value: 5,text: true,setText: function(value){
            var arrs = {'1': '极差','2': '差','3': '中等','4': '好','5': '极好'};
            this.span.text(arrs[value] || ( value + "星"));
        },choose: function(value){$("#serverLvVal").val(value)}
    })
    rate.render({
        elem: '#logisticsLv',value: 5,text: true,setText: function(value){
            var arrs = {'1': '极差','2': '差','3': '中等','4': '好','5': '极好'};
            this.span.text(arrs[value] || ( value + "星"));
        },choose: function(value){$("#logisticsLvVal").val(value)}
    })
    $.post("/cateringOrder/selectOrder",JSON.stringify({sysId:getQueryString("orderId")}),function(res){
        $("#prolist").html("")
        for(var i in res.data){
            for(var j in res.data[i].cartList){
                let yxgg = !isEmpty(res.data[i].cartList[j].spacesName) ? '<p class="t" style="font-size: 10px;margin-top: 6px;">已选规格：'+res.data[i].cartList[j].spacesName+'</p>': ""
                $("#prolist").append(
                    '<li price="'+res.data[i].cartList[j].goodsPrice+'" goodnum="'+res.data[i].cartList[j].goodsNum+'" class="on" goodsId="'+res.data[i].cartList[j].goodsId+'" internum="'+res.data[i].cartList[j].interNum+'">' +
                    '<div class="l" style="width: 28%;">' +
                    '<a><img style="border-radius:10px;" src="'+res.data[i].cartList[j].goodsImg+'" class="img-responsive" alt="..." /></a>' +
                    '</div>' +
                    '<div class="r" style="width: 72%;">' +
                    '<p class="t">'+res.data[i].cartList[j].goodsName+'</p>' +
                    '<p class="price" style="float:none;">￥'+res.data[i].cartList[j].goodsPrice+'</p>' +
                    yxgg +
                    // '<div class="jifen">送积分：'+res.data[i].cartList[j].interNum+'</div>' +
                    '<div class="jifen">x'+res.data[i].cartList[j].goodsNum+'</div>' +
                    '</div>' +
                    '</li>'
                )
                goodsIds.push(res.data[i].cartList[j].goodsId)
            }
        }
    })
    $("#subDiscuss").click(function(){
        var data = {
            descLv:$('#descLvVal').val(),
            qualityLv:$('#qualityLvVal').val(),
            serverLv:$('#serverLvVal').val(),
            logisticsLv:$('#logisticsLvVal').val(),
            content:$('#content').val(),
            goodsId: goodsIds.join(","),
            userId:userInfo.sysId
        }
        $.post("/cateringDiscuss/insert",JSON.stringify(data),function(res){
            if(res.success) {
                $.post("/cateringOrder/updateStatus",JSON.stringify({sysId:getQueryString("orderId"),orderStatus:'ORDER_STATUS_08'}), function (res) {
                    layer.msg("评价成功",{icon:1,time:1000},function(){
                        window.location.replace(document.referrer)
                    })
                })
            }
        })
    })
})
</script>
</html>
